package com.hangzhou.welbeing.welbeinginstrument.fragement;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.hangzhou.welbeing.welbeinginstrument.R;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * 杭州惟君医疗科技有限公司16
 * Created by 20433 on 2018/1/29
 */

public class ReleaseHomePagerFragment extends Fragment {
    @Bind(R.id.fragment_release_home_page_iv_pictuter)
    ImageView fragmentReleaseHomePageIvPictuter;
    private Context mcontext;
    private SimpleDateFormat sdf;
    private HashMap<String ,Integer> map = new HashMap<String ,Integer>();
    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        mcontext = context;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = View.inflate(mcontext, R.layout.fragment_release_home_page, null);
        ButterKnife.bind(this, view);
        map.put("year_2018_02_08",R.mipmap.year_2018_02_08);
        map.put("year_2018_02_09",R.mipmap.year_2018_02_09);
        map.put("year_2018_02_10",R.mipmap.year_2018_02_10);
        map.put("year_2018_02_11",R.mipmap.year_2018_02_11);
        map.put("year_2018_02_12",R.mipmap.year_2018_02_12);
        map.put("year_2018_02_13",R.mipmap.year_2018_02_13);
        map.put("year_2018_02_14",R.mipmap.year_2018_02_14);
        map.put("year_2018_02_15",R.mipmap.year_2018_02_15);
        map.put("year_2018_02_16",R.mipmap.year_2018_02_16);
        map.put("year_2018_02_17",R.mipmap.year_2018_02_17);
        map.put("year_2018_02_18",R.mipmap.year_2018_02_18);
        map.put("year_2018_02_19",R.mipmap.year_2018_02_19);
        map.put("year_2018_02_20",R.mipmap.year_2018_02_20);
        map.put("year_2018_02_21",R.mipmap.year_2018_02_21);
        map.put("year_2018_02_22",R.mipmap.year_2018_02_22);
        map.put("year_2018_02_23",R.mipmap.year_2018_02_23);
        map.put("year_2018_02_24",R.mipmap.year_2018_02_24);
        map.put("year_2018_02_25",R.mipmap.year_2018_02_25);
        map.put("year_2018_02_26",R.mipmap.year_2018_02_26);
        map.put("year_2018_02_27",R.mipmap.year_2018_02_27);
        map.put("year_2018_02_28",R.mipmap.year_2018_02_28);
        map.put("year_2018_03_01",R.mipmap.year_2018_03_01);
        map.put("year_2018_03_02",R.mipmap.year_2018_03_02);
        return view;
    }

    @Override
    public void onStart() {
        super.onStart();
        sdf = new SimpleDateFormat("yyyy_MM_dd");
        String date = "year_"+sdf.format(new Date());
        for (String key : map.keySet()) {
            if(key.equals(date)){
                fragmentReleaseHomePageIvPictuter.setBackgroundResource(map.get(key));
            }
        }
        
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        ButterKnife.unbind(this);
    }
}
